PACKAGE=trickle
VERSION := 1.06
ARCHIVEVER := ${VERSION}

BINDIR      := /usr/bin/
RPM=$(HOME)/rpm

PRODUCT      = "PCLinuxOS 2007"
export PRODUCT

TEXTDOMAIN   = ${PACKAGE}

MSGFMT       = /usr/bin/msgfmt

TARBALL      = $(PACKAGE)-i18n-$(ARCHIVEVER).tar.gz

RPMSOURCEDIR = $(shell rpm --eval '%_sourcedir')

SOURCES = $(TARBALL)

RPMSOURCES = ${patsubst %,$(RPMSOURCEDIR)/%,${SOURCES}}

LOCALDISTDIR = $(PACKAGE)-i18n-$(VERSION)

bindir=/usr/bin
sbindir=/usr/sbin
datadir=/usr/share
cachedir=/var/cache
localedir=$(datadir)/locale
libdir=/usr/lib
etcdir=/etc

POS := ${wildcard */${TEXTDOMAIN}.po}
MOS := ${patsubst %.po,%.mo,${POS}}
INSTLOCALES := ${patsubst %/${TEXTDOMAIN}.po,%,${POS}}

.PHONY: all clean install distclean srccopy ${INSTLOCALES}

all: ${MOS}

${MOS}: %/${TEXTDOMAIN}.mo : %/${TEXTDOMAIN}.po
	$(MSGFMT) -o $@ $<

${INSTLOCALES}: %: %/${TEXTDOMAIN}.mo
	install -d -m 755 $(DESTDIR)/$(localedir)/$@/LC_MESSAGES/
	install -m 644 $< $(DESTDIR)/$(localedir)/$@/LC_MESSAGES/

install: all ${INSTLOCALES}

clean:
	rm -f */${TEXTDOMAIN}.mo
	rm -f $(TARBALL)

distclean: clean

$(TARBALL): ${MOS}
	if [ ! -d $(LOCALDISTDIR) ]; then  mkdir $(LOCALDISTDIR); fi
	tar cp --exclude=.svn --exclude=$(LOCALDISTDIR) --exclude=*.tar.bz2 --exclude=*.tar.gz . | tar xp -C $(LOCALDISTDIR)
	tar czvf $(TARBALL) $(LOCALDISTDIR)
	rm -rf $(LOCALDISTDIR)

srccopy: $(RPMSOURCES)

${RPMSOURCES}: $(RPMSOURCEDIR)/%: %
	cp -f $< $@
